Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
The path-type npm package is a simple utility that provides functions to check the type of a filesystem path. It can determine whether a path is a file, directory, symbolic link, etc. It is useful for validating paths and handling them conditionally based on their type.
isFile
Checks if a path is a file.
const pathType = require('path-type');
pathType.isFile('source.js').then(isFile => {
console.log(isFile); //=> true or false
});
isDirectory
Checks if a path is a directory.
const pathType = require('path-type');
pathType.isDirectory('source').then(isDirectory => {
console.log(isDirectory); //=> true or false
});
isSymlink
Checks if a path is a symbolic link.
const pathType = require('path-type');
pathType.isSymlink('link').then(isSymlink => {
console.log(isSymlink); //=> true or false
});
fs-extra is a package that extends the built-in fs module, providing additional methods and also includes the functionality to check path types. It is more comprehensive than path-type as it includes file system operations beyond type checking.
fs-promise is a package that promisifies the Node.js fs module and adds support for promises to file system operations, including checking if a path is a file or directory. It is similar to path-type but is integrated with the fs module's other functionalities.
Check if a path is a file, directory, or symlink
$ npm install path-type
const pathType = require('path-type');
pathType.file('package.json').then(isFile => {
console.log(isFile);
//=> true
})
Returns a Promise
for a boolean
of whether the path is the checked type.
Returns a boolean
of whether the path is the checked type.
MIT © Sindre Sorhus
FAQs
Check if a path is a file, directory, or symlink
We found that path-type demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.